package com.cutefool.samples.transactional.scene01;

import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class Demo01Right {


    // 事务生效，通过代理类调用
    public void m1() {
        ((Demo01Right) AopContext.currentProxy()).m2();
    }

    @Transactional(rollbackFor = Exception.class)
    public void m2() {
        log.info("this is m2.");
    }

}
